import request from '@/utils/request';

/**
 * 优惠券列表
 * @param query 
 * @returns 
 */
export const listPage = (query) => {
  return request({
    url: '/coupon/list',
    method: 'get',
    params: query
  });
};

/**
 * 优惠券详情
 * @param query 
 * @returns 
 */
export const info = (query) => {
  return request({
    url: `/coupon/detail/${query.id}`,
    method: 'get',
    // params: {
    //   id: query.id
    // }
  });
};

/**
 * 优惠券使用记录
 * @param query 
 * @returns 
 */
export const useInfoApi = (query) => {
  return request({
    url: `/coupon/record/${query.path.id}`,
    method: 'get',
    params: query.query
  });
};

// 新增
export const add = (query) => {
  return request({
    url: `/coupon`,
    method: 'post',
    data: query
  });
};

// 编辑
export const edit = (query) => {
  return request({
    url: `/coupon`,
    method: 'put',
    data: query
  });
};

// 上下架
export const changeStatusApi = (query) => {
  return request({
    url: `/coupon/enable/${query.id}`,
    method: 'put',
  });
};

// 删除
export const del = (query) => {
  return request({
    url: `/coupon/remove/${query.id}`,
    method: 'delete',
  });
};